package com.bupt.cosmfl.cosmflweb.exception;

import com.bupt.cosmfl.cosmflweb.constant.ResponseResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author fangtiewei
 * @Date 2021/7/25 14:59
 * @Description  全局捕获异常并处理
 */
@ControllerAdvice
public class CustomerExceptionHandler {

    @ResponseBody
    @ExceptionHandler(BusinessException.class)
    public ResponseResult<Object> businessExceptionHandler(BusinessException e){
        return ResponseResult.error(e.getErrCode(),e.getMessage());
    }
}
